home *** CD-ROM | disk | FTP | other *** search
- (*----------------------------------------------------------------------*)
- (* Handle_Keyboard_Input --- Read keyboard input in terminal mode *)
- (*----------------------------------------------------------------------*)
-
- PROCEDURE Handle_Keyboard_Input( VAR Done : BOOLEAN;
- VAR Reset_Requested : BOOLEAN;
- VAR ClearScreen_Requested : BOOLEAN );
-
- (*----------------------------------------------------------------------*)
- (* *)
- (* Procedure: Handle_Keyboard_Input *)
- (* *)
- (* Purpose: Reads keyboard input in terminal modes *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* Handle_Keyboard_Input *)
- (* *)
- (*----------------------------------------------------------------------*)
-
- VAR
- Ch : CHAR;
- Save_Screen_Line : INTEGER;
-
- BEGIN (* Handle_Keyboard_Input *)
- (* Read input character *)
- READ( Kbd , Ch );
- (* Assume not reset *)
- Reset_Requested := FALSE;
- (* Assume not clear screen *)
- ClearScreen_Requested := FALSE;
- (* Process it *)
- IF ( Ch = CHR( ESC ) ) THEN
- IF KeyPressed THEN
- BEGIN (* Escape AND KeyPressed *)
-
- (* Get character following escape *)
- READ( Kbd , Ch );
-
- IF ( Ch = CHR( SI ) ) THEN
- Reset_Requested := TRUE
- ELSE
- BEGIN (* Not terminal reset *)
-
- Save_Screen_Line := Max_Screen_Line;
-
- Process_Command( Ch, TRUE, PibTerm_Command );
-
- CASE PibTerm_Command OF
- Null_Command: ;
- ClearSy : ClearScreen_Requested := TRUE;
- ELSE
- Execute_Command( PibTerm_Command, Done, FALSE );
- END (* CASE *);
-
- Reset_Requested := ( Max_Screen_Line <> Save_Screen_Line );
-
- END (* Not terminal reset *);
-
- EXIT;
-
- END (* Escape AND KeyPressed *)
- ELSE (* Escape only *)
- IF Async_XOff_Received THEN
- BEGIN
- Async_XOff_Received := FALSE;
- IF Do_Status_Line THEN
- Write_To_Status_Line( ' ', 65 );
- EXIT;
- END;
- (* Handle other characters *)
- CASE ORD( Ch ) OF
-
- BS: Ch := BS_Char;
-
- DEL: Ch := Ctrl_BS_Char;
-
- ELSE IF Send_Upper_Case_Only THEN
- Ch := UpCase( Ch );
-
- END (* CASE *);
- (* Put char in received buffer if *)
- (* local echo on so we display it *)
- (* later on. *)
-
- IF Local_Echo THEN Async_Stuff( Ch );
-
- (* Learn this character if doing a *)
- (* learn script. *)
- IF Script_Learn_Mode THEN
- Learn_A_Character( Ch );
- (* Send this character to remote. *)
- Async_Send( Ch );
- (* If Ch = CR and New_Line mode, send *)
- (* a LF as well. *)
- IF ( Ch = CHR( CR ) ) THEN
- IF New_Line THEN
- Async_Send( CHR( LF ) );
-
- (* Stuff character into keyboard line, *)
- (* except backspaces/deletes *)
-
- CASE ORD( Ch ) OF
- DEL,
- BS : IF ( Keyboard_Line_Pos > 0 ) THEN
- Keyboard_Line_Pos := PRED( Keyboard_Line_Pos );
- ELSE
- IF ( Keyboard_Line_Pos = 255 ) THEN
- MOVE( Keyboard_Line[2], Keyboard_Line[1], 254 )
- ELSE
- Keyboard_Line_Pos := SUCC( Keyboard_Line_Pos );
-
- Keyboard_Line[Keyboard_Line_Pos] := Ch;
- Keyboard_Line[0] := CHR( Keyboard_Line_Pos );
-
- IF ( Ch = CHR( CR ) ) THEN
- Keyboard_Line_Pos := 0;
-
- END (* CASE *);
-
- END (* Handle_Keyboard_Input *);